<?php

namespace Plugins\Edge\Common\Validate;

use App\Common\Validate\AbstractValidate;

class NewsValidate extends AbstractValidate
{
    protected function allRules(): array
    {
        return [
            "id|ID"       => ["require"],
            "title|标题" => ["require"],
            "intro|简介" => ["require"],
            "tag|标签"  => ["require"],
            "is_top|置顶" => ["require"],
            "cover|封面" => ["require"],
            "view_number|浏览数" => ["require"],
            "author|作者" => ["require"],
            "status|状态" => ["require"],
            "content|内容" => ["require"],
        ];
    }

    public function allMessages(): array
    {
        return [];
    }

    public function sceneStore(): static
    {
        return $this->remove('id', 'require')
            ->remove(['view_number' => 'require', 'author' => 'require']);
    }

    public function sceneUpdate(): static
    {
        return $this->remove(['view_number' => 'require', 'author' => 'require']);
    }

    public function sceneDestroy(): static
    {
        return $this->rule(['ids|要删除的数据' => 'require|array'])->only(['ids']);
    }

    public function sceneSwitchToggle(): static
    {
        return $this->rule(['ids|要删除的数据' => 'require|array'])->only(['id']);
    }
}
